package com.dap.cms.base.impl;


import com.dap.dao.BasePo;
import com.dap.dao.DaoSupport;
import com.dap.dao.model.QueryResult;
import com.dap.cms.base.IBaseService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @description: 基本服务接口实现类
 * @author: Fesine
 * @createTime:2017/10/25
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2017/10/25
 */

public abstract class BaseServiceImpl<T extends BasePo>  implements IBaseService<T> {

    @Autowired
    protected DaoSupport daoService;

    @Override
    public  int save(T po) {
        return daoService.insert(po);
    }

    @Override
    public  int update(T po) {
        return daoService.update(po);
    }

    @Override
    public  int delete(T po) {
        return daoService.delete(po);
    }

    @Override
    public  T get(T po) {
        return daoService.selectOne(po);
    }

    @Override
    public List<T> listAll(T po) {
        return daoService.selectList(po);
    }

    @Override
    public QueryResult<T> listPage(T po, int page, int limit) {
        return daoService.selectQueryResult(po,page,limit);
    }

    @Override
    public int count(T po) {
        return daoService.count(po);
    }

    public void setDaoService(DaoSupport daoService) {
        this.daoService = daoService;
    }
}
